package com.etc.homework;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author: knowno
 * @create: 2024-09-12 09:02
 * @Version 1.0
 **/
public class User {
    private String id;
    private String username;
    private String userpass;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(id, user.id) && Objects.equals(username, user.username) && Objects.equals(userpass, user.userpass);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, userpass);
    }


    /**
     * 因为需要将数据保存到文件中，所以这里做了一个自定义的拼接的处理.
     *
     * @return
     */
    public String saveinfo() {
        return username + "," + userpass;
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", username='" + username + '\'' +
                ", userpass='" + userpass + '\'' +
                '}';
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUserpass() {
        return userpass;
    }

    public void setUserpass(String userpass) {
        this.userpass = userpass;
    }

    public User() {
    }

    public User(String id, String username, String userpass) {
        this.id = id;
        this.username = username;
        this.userpass = userpass;
    }
}
